<%@page import="java.util.List"%>
<%@page import="team.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page errorPage="error.jsp" %>
<%@ include file="header.jspf" %>

<% 
Team team = TeamFabric.getInstance(((Integer)session.getAttribute("sport")).intValue());
String sport = null;
Integer sportId = (Integer)session.getAttribute("sport");
switch(sportId.intValue()) {
       case 1:
            sport = "football";
            break;
       case 2:
            sport = "basketball";
            break;
       case 3:
            sport = "hockey";
            break;
}

if (request.getParameter("teamId")!= null) {
    session.setAttribute("teamId", new Integer(request.getParameter("teamId")));
}
%>

			<br class=clear>

			<div class="sportname">
                            <h1><%= sport %> -> teams -> <jsp:include page="sport?page=team&mode=name" /> -> info</h1>
			</div>



<nav class="submenu">
    <ul>
        <li class="item">
            <a href="teams.jsp">teams</a>
        </li>

        <li class="item">
            <a href="players.jsp">players</a>
        </li>
    </ul>
</nav>

			<br class=clear>
<%@ include file="team_submenu.jspf" %>

			<section class="middle">
				<div class="teaser"/>
				<br class=clear>
				<div class="teaser"  style="width:100%">
					<div class="gray_teaser star_teaser">
						<br class="clear">
						<div class="teaser-block-left f-left star_teaser">
							<table class="teaser-table" cellspacing="0" cellpadding="0">
							<tbody>
								<thead>
<%
if (team != null) {
    List attrs = team.getAttrsNames();
    for(int i=0; i < attrs.size(); i++) {
        if (!attrs.get(i).equals("name") && !attrs.get(i).equals("id") && !attrs.get(i).equals("sportId")) {
  
%>
									<th><%= attrs.get(i) %> </th>
<% 
        }
   }
}
%>
								</thead>

								<tr>
<% if (request.getParameter("mode")!= null && request.getParameter("mode").equals("edit")) {
%>
                                                                    <jsp:include page="sport?page=team&mode=edit" />
<% }
else {
%>
                                                                    <jsp:include page="sport?page=team" />
<%
}                          
%>                                        
                                                                       
								</tr>
							</tbody>
						</table>
					</div>

					<div class="border_teaser"></div>

				</div>
                                <br class="clear"/>
                                
<% if (request.getParameter("mode")!= null && request.getParameter("mode").equals("edit")) {
%>                                                                                                          		
                                
                                <button class=sportbutton onclick="save('team')">save</button>
                                &nbsp;&nbsp;
                                <button class=sportbutton onclick="window.location='team.jsp';">cancel</button>				

<% }
else {
%>
                               <button class=sportbutton onclick="window.location='team.jsp?mode=edit';">edit</button>
				&nbsp;&nbsp;
				<button class=sportbutton onclick="remove('team')">remove</button>
<%
}
%>
			</div>

		</section>
                        
<%@ include file="footer.jspf" %>